package com.examiner.dao;

import com.examiner.bean.CommonPerson;
import com.examiner.bean.test.TestDB;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface TestDBDao  extends JpaRepository<TestDB,Integer>, JpaSpecificationExecutor<TestDB> {

    @Query(value = "select count(test_id) from testdb where test_title like %?1% or test_create like %?1%",nativeQuery = true)
    int getTotal(String query);

    @Query(value = "select * from testdb where test_title like %?3% or test_create like %?3% limit ?1,?2 ",nativeQuery = true)
    List<TestDB> findByQuery(int i, int pageSize, String query);

    @Query(value = "select * from testdb where (test_title like %?3% or test_create like %?3%) and test_create in ?4 limit ?1,?2",nativeQuery = true)
    List<TestDB> getListByUser(int i, int pageSize, String query, List<String> userList);

    @Query(value = "select count(test_id) from testdb where (test_title like %?1% or test_create like %?1%) and test_create in ?2 ",nativeQuery = true)
    int getListTotalByUser(String query, List<String> userList);

    @Query(value = "select test_id from testdb where test_title like %?1%", nativeQuery = true)
    List<Integer> findSelectByTitle(String testTitle);
}
